Optimal. Leaf size=41 \[ -b \text {Ci}\left (\frac {2 b}{x}\right ) \sin (2 a)+x \sin ^2\left (a+\frac {b}{x}\right )-b \cos (2 a) \text {Si}\left (\frac {2 b}{x}\right ) \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.06, antiderivative size = 41, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 6, integrand size = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.600, Rules used = {3442, 3394, 12,
3384, 3380, 3383} \begin {gather*} -b \sin (2 a) \text {CosIntegral}\left (\frac {2 b}{x}\right )-b \cos (2 a) \text {Si}\left (\frac {2 b}{x}\right )+x \sin ^2\left (a+\frac {b}{x}\right ) \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 3380
Rule 3383
Rule 3384
Rule 3394
Rule 3442
Rubi steps
\begin {align*} \int \sin ^2\left (a+\frac {b}{x}\right ) \, dx &=-\text {Subst}\left (\int \frac {\sin ^2(a+b x)}{x^2} \, dx,x,\frac {1}{x}\right )\\ &=x \sin ^2\left (a+\frac {b}{x}\right )-(2 b) \text {Subst}\left (\int \frac {\sin (2 a+2 b x)}{2 x} \, dx,x,\frac {1}{x}\right )\\ &=x \sin ^2\left (a+\frac {b}{x}\right )-b \text {Subst}\left (\int \frac {\sin (2 a+2 b x)}{x} \, dx,x,\frac {1}{x}\right )\\ &=x \sin ^2\left (a+\frac {b}{x}\right )-(b \cos (2 a)) \text {Subst}\left (\int \frac {\sin (2 b x)}{x} \, dx,x,\frac {1}{x}\right )-(b \sin (2 a)) \text {Subst}\left (\int \frac {\cos (2 b x)}{x} \, dx,x,\frac {1}{x}\right )\\ &=-b \text {Ci}\left (\frac {2 b}{x}\right ) \sin (2 a)+x \sin ^2\left (a+\frac {b}{x}\right )-b \cos (2 a) \text {Si}\left (\frac {2 b}{x}\right )\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.06, size = 41, normalized size = 1.00 \begin {gather*} -b \text {Ci}\left (\frac {2 b}{x}\right ) \sin (2 a)+x \sin ^2\left (a+\frac {b}{x}\right )-b \cos (2 a) \text {Si}\left (\frac {2 b}{x}\right ) \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.06, size = 52, normalized size = 1.27
method | result | size |
derivativedivides | \(-b \left (-\frac {x}{2 b}+\frac {\cos \left (2 a +\frac {2 b}{x}\right ) x}{2 b}+\sinIntegral \left (\frac {2 b}{x}\right ) \cos \left (2 a \right )+\cosineIntegral \left (\frac {2 b}{x}\right ) \sin \left (2 a \right )\right )\) | \(52\) |
default | \(-b \left (-\frac {x}{2 b}+\frac {\cos \left (2 a +\frac {2 b}{x}\right ) x}{2 b}+\sinIntegral \left (\frac {2 b}{x}\right ) \cos \left (2 a \right )+\cosineIntegral \left (\frac {2 b}{x}\right ) \sin \left (2 a \right )\right )\) | \(52\) |
risch | \(\frac {\pi \,\mathrm {csgn}\left (\frac {b}{x}\right ) {\mathrm e}^{-2 i a} b}{2}-\sinIntegral \left (\frac {2 b}{x}\right ) {\mathrm e}^{-2 i a} b +\frac {i \expIntegral \left (1, -\frac {2 i b}{x}\right ) {\mathrm e}^{-2 i a} b}{2}-\frac {i b \expIntegral \left (1, -\frac {2 i b}{x}\right ) {\mathrm e}^{2 i a}}{2}+\frac {x}{2}-\frac {x \cos \left (\frac {2 a x +2 b}{x}\right )}{2}\) | \(85\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [C] Result contains complex when optimal does not.
time = 0.37, size = 66, normalized size = 1.61 \begin {gather*} -\frac {1}{2} \, {\left ({\left (-i \, {\rm Ei}\left (\frac {2 i \, b}{x}\right ) + i \, {\rm Ei}\left (-\frac {2 i \, b}{x}\right )\right )} \cos \left (2 \, a\right ) + {\left ({\rm Ei}\left (\frac {2 i \, b}{x}\right ) + {\rm Ei}\left (-\frac {2 i \, b}{x}\right )\right )} \sin \left (2 \, a\right )\right )} b - \frac {1}{2} \, x \cos \left (\frac {2 \, {\left (a x + b\right )}}{x}\right ) + \frac {1}{2} \, x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.36, size = 56, normalized size = 1.37 \begin {gather*} -x \cos \left (\frac {a x + b}{x}\right )^{2} - b \cos \left (2 \, a\right ) \operatorname {Si}\left (\frac {2 \, b}{x}\right ) - \frac {1}{2} \, {\left (b \operatorname {Ci}\left (\frac {2 \, b}{x}\right ) + b \operatorname {Ci}\left (-\frac {2 \, b}{x}\right )\right )} \sin \left (2 \, a\right ) + x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \sin ^{2}{\left (a + \frac {b}{x} \right )}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 153 vs.
\(2 (41) = 82\).
time = 5.27, size = 153, normalized size = 3.73 \begin {gather*} -\frac {2 \, a b^{2} \operatorname {Ci}\left (-2 \, a + \frac {2 \, {\left (a x + b\right )}}{x}\right ) \sin \left (2 \, a\right ) - 2 \, a b^{2} \cos \left (2 \, a\right ) \operatorname {Si}\left (2 \, a - \frac {2 \, {\left (a x + b\right )}}{x}\right ) - \frac {2 \, {\left (a x + b\right )} b^{2} \operatorname {Ci}\left (-2 \, a + \frac {2 \, {\left (a x + b\right )}}{x}\right ) \sin \left (2 \, a\right )}{x} + \frac {2 \, {\left (a x + b\right )} b^{2} \cos \left (2 \, a\right ) \operatorname {Si}\left (2 \, a - \frac {2 \, {\left (a x + b\right )}}{x}\right )}{x} - b^{2} \cos \left (\frac {2 \, {\left (a x + b\right )}}{x}\right ) + b^{2}}{2 \, {\left (a - \frac {a x + b}{x}\right )} b} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.02 \begin {gather*} \int {\sin \left (a+\frac {b}{x}\right )}^2 \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________